// pages/notice/view.js
const config = require('../../config.js');
const util = require('../../utils/util.js');

Page({
  data:{},
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    var that = this
    wx.request({
            url: config.host+'/api/notice/getById?id='+options.id,
            method: 'GET',
            data: {},
            header: {
                'Accept': 'application/json'
            },
            success: function(res) {
                that.setData({
                    noticeItem: res.data,
                    created:util.formatTimeFromTimestamp(res.data.created)
                });
            }
        });

    wx.request({
            url: config.host+'/api/comment/getCommentList?infoType=1&infoId='+options.id,
            method: 'GET',
            data: {},
            header: {
                'Accept': 'application/json'
            },
            success: function(res) {
                that.setData({
                    comments: res.data
                });
            }
        })
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  comment_add_tap:function()
  {
    wx.navigateTo({
      url: '../comment/add'
    })
  }
})